package com.derbysoft.lowcostadapter.schedule.sync.impl;

import com.derbysoft.lowcostadapter.dswitch2.service.helper.Constant;
import com.derbysoft.lowcostadapter.schedule.parse.ParseRoomOccupancyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SyncRoomOccupancyServiceImpl extends SyncFromFileServiceBase {
    protected static final Logger logger = LoggerFactory.getLogger(SyncRoomOccupancyServiceImpl.class);
    public static final String SYNC_ROOM_OCCUPANCY_TIMESTAMP = "SYNC_ROOM_OCCUPANCY_TIMESTAMP";

    private ParseRoomOccupancyService parseRoomOccupancyService;

    @Override
    protected boolean doSync() {
        try {
            return parseRoomOccupancyService.importRoomOccupancy(getFileInputStream());
        } catch (Exception ex) {
            logger.error(ex.getMessage(), ex);
        }
        return false;
    }

    @Override
    protected String getTimestampVariableName() {
        return SYNC_ROOM_OCCUPANCY_TIMESTAMP;
    }

    @Override
    protected String getConfigVariableName() {
        return Constant.SYNC_ROOM_OCCUPANCY_CONFIG;
    }

    public void setParseRoomOccupancyService(ParseRoomOccupancyService parseRoomOccupancyService) {
        this.parseRoomOccupancyService = parseRoomOccupancyService;
    }
}
